<!DOCTYPE html>
<script src="../../../../../resources/testharness.js"></script>
<script src="../../../../../resources/testharnessreport.js"></script>
<script src="../../../../../fast/spatial-navigation/resources/snav-testharness.js"></script>

<video id="video" controls></video>
<button id="button"></button>

<script>
  let video = document.getElementById("video");
  let button = document.getElementById("button");
  let fullscreened = new Promise((resolve) => {
    document.addEventListener('fullscreenchange', resolve);
  });

  button.addEventListener('click', function() {
    video.requestFullscreen();
  });

  promise_test(async () => {
    button.focus();
    eventSender.keyDown('Enter');

    await snav.rAF();
    await fullscreened;

    assert_equals(window.internals.interestedElement,
                  video,
                  "Video element should have interest.");
    assert_equals(document.activeElement,
                  video,
                  "Video element should be focused.");
  }, "Spat-Nav resets gracefully after focused editable becomes display:none.");
</script>
